package lt.inkredibl.iit;

import java.awt.geom.Line2D.Double;

public class ConstraintLeft
	extends Constraint
{
	public ConstraintLeft(double x1)
	{
		super(x1);
	}

	public boolean outside(double val)
	{
		return val < getC();
	}

	public boolean inside(double val)
	{
		return val >= getC();
	}

	public void crop(Double ln)
	{
		if (outside(ln.x1))
		{
			double mul = diffC(ln.x1) / diff(ln);
			ln.x1 = getC();
			ln.y1 += (ln.y2 - ln.y1) * mul;
		}
		else
		{
			double mul = diffC(ln.x2) / diff(ln);
			ln.x2 = getC();
			ln.y2 += (ln.y1 - ln.y2) * mul;
		}
	}

	@Override
	public double getVal1(Double ln)
	{
		return ln.x1;
	}

	@Override
	public double getVal2(Double ln)
	{
		return ln.x2;
	}

}
